# @Time : 2021/4/3 9:58
# @Author : Fioman 
# @Phone : 13149920693
"""
项目用到的配置文件,主要用来保存项目的一些配置,例如是否是调试模式,一些路径配置问题
"""
import os
import sys

PROJECT_NAME = "weiergao_4pin"
# 使用的数据库名称
DATABASE_NAME = "params_{}".format(PROJECT_NAME)
# 是否是开发者模式
DEVELOP = True if len(sys.argv) >= 2 else False

# 主线程是否在运行的标志
IS_MAIN_ALIVE = False

# 机械手放板方向
MANIPULATOR_DIRECTION = True

# 项目的根目录,也就是python目录所在的绝对路径
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
WEB_PATH = os.path.join(BASE_DIR, "web")
ZMC_LIB_PATH = os.path.join(BASE_DIR, r'dll\zmotion.dll')
AUX_ZMC_LIB_PATH = os.path.join(BASE_DIR, r'dll\zauxdll.dll')
cameraDriverDir = r"C:\Program Files (x86)\Common Files\MVS\Runtime\Win64_x64"
CAMERA_LIB_PATH = os.path.join(cameraDriverDir, "MvCameraControl.dll")
CALC_ARGS_TXT_PATH = os.path.join(BASE_DIR, r"calcArgs.txt")

MSG_RECV_PATH = os.path.join(BASE_DIR, r"hd_socket\message_recv.xml")
MSG_SEND_PATH = os.path.join(BASE_DIR, r"hd_socket\message_send.xml")
EAP_SEND_MOCK_PATH = os.path.join(BASE_DIR, r"hd_socket\eap_mock_message_send.xml")

EAP_DEBUG_DIR = os.path.join(BASE_DIR, "eap_debug")
# 图片保存的路径
# 1. 保存AI训练图片的路径
TRAIN_DATASET_DIR = r"D:\raw\raw_ai"
# 2. 保存前铡刀标定的图片路径
CUTTER_CAM_CAL_DIR_BIG = r"D:\cutter_raw\raw_calc_big"
# 3. 保存后铡刀标定的图片路径
CUTTER_CAM_CAL_DIR_SMALL = r"D:\cutter_raw\raw_calc_small"
# 4. 保存首板的图片路径
FIRST_CUT_BOARD_DIR_4PIN = r"D:\raw\4pin\raw_first_board\first_raw_cut"
# 5. 保存识别成功的图片路径
RAW_OK_DIR_4PIN = r"D:\raw\4pin\raw_ok"
# 6. 保存识别失败的图片路径
RAW_FAIL_DIR_4PIN = r"D:\raw\4pin\raw_fail"
# 7. 保存物料检测未通过的图片路径
RAW_TOTALBOARD_ERROR_DIR_4PIN = r"D:\raw\4pin\raw_totalboard_error"
# 8. 保存前铡刀报警的图片路径
CUTTER_RAW_BEGIN_DIR_BIG = r"D:\big_cutter_raw\raw_begin"
# 9. 保存后铡刀报警的图片路径
CUTTER_RAW_BEGIN_DIR_SMALL = r"D:\small_cutter_raw\raw_begin_back"
# 10. 保存切线图的路径
RAW_CUT_LINE_DIR_4PIN = r"D:\raw\4pin\raw_cut"
# 11. 日志的保存目录
DEBUG_DIR = os.path.join(BASE_DIR, "debug")
# 12. 标定的图片的保存目录
CALIBRATION_DIR = r"D:\raw\raw_calibration"
# 13. 图像拼接使用的目录
IMAGE_JOINT_DIR = r"D:\raw\raw_joint"
# 14. 统计物料宽高的目录
COUNT_BOARD_SIZE_DIR = r"D:\raw\raw_joint\count_board_size"
# 15. 铡刀终点检测的图片保存
CUTTER_RAW_FINAL_DIR_BIG = r"D:\big_cutter_raw\raw_final"
# 16. 铡刀起点检测的结果图片
CUTTER_RAW_BEGIN_RES_DIR_BIG = r"D:\big_cutter_raw\raw_begin_res"
# 17. 铡刀终点检测的结果图片
CUTTER_RAW_FINAL_RES_DIR_BIG = r"D:\big_cutter_raw\raw_final_res"
# 18. 铡刀终点检测的图片保存
CUTTER_RAW_FINAL_DIR_SMALL = r"D:\small_cutter_raw\raw_final"
# 19. 铡刀起点检测的结果图片
CUTTER_RAW_BEGIN_RES_DIR_SMALL = r"D:\small_cutter_raw\raw_begin_res"
# 20. 铡刀终点检测的结果图片
CUTTER_RAW_FINAL_RES_DIR_SMALL = r"D:\small_cutter_raw\raw_final_res"
# 21. 保存文件,界面上点击保存的时候,会将文件,保存到这个目录下
FILE_SAVE_DIR = r"D:\file_save"  # 保存文件的目录
# 22. 数据库备份的目录
DATA_BASE_DUMP_DIR = r"D:\db_data\data_dump"
# 23. 数据库导入的目录
DATA_BASE_IMPORT_DIR = r"D:\db_data\data_import"
# 24.
FIRST_SIZE_OK_DIR_4PIN = r"D:\raw\4pin\raw_first_board\size_check_ok"

FIRST_CUT_BOARD_DIR_6PIN = r"D:\raw\6pin\raw_first_board\first_raw_cut"
FIRST_SIZE_OK_DIR_6PIN = r"D:\raw\6pin\raw_first_board\size_check_ok"
RAW_OK_DIR_6PIN = r"D:\raw\6pin\raw_ok"
# 6. 保存识别失败的图片路径
RAW_FAIL_DIR_6PIN = r"D:\raw\6pin\raw_fail"
# 7. 保存物料检测未通过的图片路径
RAW_TOTALBOARD_ERROR_DIR_6PIN = r"D:\raw\6pin\raw_totalboard_error"
RAW_CUT_LINE_DIR_6PIN = r"D:\raw\6pin\raw_cut"

# 然后就是项目启动的时候自检,这些路径是否都存在,如果不存在就创建
filePathList = [
    TRAIN_DATASET_DIR,  # 1
    CUTTER_CAM_CAL_DIR_BIG,  # 2
    CUTTER_CAM_CAL_DIR_SMALL,  # 3
    FIRST_CUT_BOARD_DIR_4PIN,  # 4
    RAW_OK_DIR_4PIN,  # 5
    RAW_FAIL_DIR_4PIN,  # 6
    RAW_TOTALBOARD_ERROR_DIR_4PIN,  # 7
    CUTTER_RAW_BEGIN_DIR_BIG,  # 8
    CUTTER_RAW_BEGIN_DIR_SMALL,  # 9
    RAW_CUT_LINE_DIR_4PIN,  # 10
    DEBUG_DIR,  # 11
    CALIBRATION_DIR,  # 12
    IMAGE_JOINT_DIR,  # 13
    COUNT_BOARD_SIZE_DIR,  # 14
    CUTTER_RAW_FINAL_DIR_BIG,  # 15
    CUTTER_RAW_BEGIN_RES_DIR_BIG,  # 16
    CUTTER_RAW_FINAL_RES_DIR_BIG,  # 17
    CUTTER_RAW_FINAL_DIR_SMALL,  # 18
    CUTTER_RAW_BEGIN_RES_DIR_SMALL,  # 19
    CUTTER_RAW_FINAL_RES_DIR_SMALL,  # 20
    FILE_SAVE_DIR,  # 21
    DATA_BASE_DUMP_DIR,  # 22
    DATA_BASE_IMPORT_DIR,  # 23
    FIRST_SIZE_OK_DIR_4PIN,  # 24
    FIRST_CUT_BOARD_DIR_6PIN,
    FIRST_SIZE_OK_DIR_6PIN,
    RAW_OK_DIR_6PIN,
    # 6. 保存识别失败的图片路径
    RAW_FAIL_DIR_6PIN,
    # 7. 保存物料检测未通过的图片路径
    RAW_TOTALBOARD_ERROR_DIR_6PIN,
    RAW_CUT_LINE_DIR_6PIN,
    EAP_DEBUG_DIR,
]
for filePath in filePathList:
    if not os.path.exists(filePath):
        os.makedirs(filePath)

showState = False  # 是否显示图像
# Eap上一个工单是否在生产中
eapIsInProduce = False
# Eap是否可以切换工单
eapCanChangeOrderFlag = False
